package com.chixing.ih.module.programmer.mapper.provider;

import com.github.pagehelper.ISelect;
import org.apache.ibatis.jdbc.SQL;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘岩
 * Date: 2020-10-01
 * Time: 10:37
 *
 * @version 1.0
 */
public class TechnologyCreditMapperProvider {
    public String listOrdNum() {
        return new SQL() {{
            SELECT("count(1) number,date_format(order_begin_time,'%Y') date");
            FROM("tbl_order");
            WHERE("receive_task_user_id =#{userId} AND date_format(order_begin_time,'%Y') BETWEEN date_format(DATE_ADD(CURDATE(), INTERVAL - 5 YEAR),'%Y') AND date_format( CURDATE(), '%Y' )");
            GROUP_BY("date_format(order_begin_time,'%Y')");
            ORDER_BY("date_format(order_begin_time,'%Y')");
        }}.toString();
    }

    public String listChargebackOrdNum() {
        return new SQL() {{
            SELECT("count(1) number,date_format( order_begin_time, '%Y' ) date");
            FROM("tbl_order");
            WHERE("receive_task_user_id=#{userId} AND is_deleted=1 AND date_format(order_begin_time,'%Y') BETWEEN date_format(DATE_ADD(CURDATE(), INTERVAL - 5 YEAR),'%Y') AND date_format( CURDATE(), '%Y' )");
            GROUP_BY("date_format(order_begin_time,'%Y')");
            ORDER_BY("date_format(order_begin_time,'%Y')");
        }}.toString();

    }

    public String listPosComNum() {
        return new SQL() {{
            SELECT("count( 1 ) number,date_format( create_time, '%Y' ) date");
            FROM("tbl_evaluate");
            WHERE("( attitude_score + punctuality_score + skill_score )> 7 AND user_evaluated_id =#{userId} AND date_format( create_time, '%Y' )BETWEEN date_format( DATE_ADD( CURDATE(), INTERVAL - 5 YEAR ), '%Y' ) AND date_format( CURDATE(), '%Y' )");
            GROUP_BY("date_format( create_time, '%Y')");
            ORDER_BY("date_format(create_time,'%Y')");
        }}.toString();

    }

    public String listTotalIntegral() {
        return new SQL() {{
            SELECT("sum( attitude_score + punctuality_score + skill_score ) number,date_format( create_time, '%Y' ) date");
            FROM("tbl_evaluate");
            WHERE("user_evaluated_id=#{userId} AND date_format( create_time, '%Y' ) BETWEEN date_format( DATE_ADD( CURDATE(), INTERVAL - 5 YEAR ), '%Y' ) AND date_format( CURDATE(), '%Y' ) ");
            GROUP_BY("date_format( create_time, '%Y' )");
            ORDER_BY("date_format( create_time, '%Y' )");
        }}.toString();
    }


}
